package com.droid.activities;

// Doctor's profile

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.StringTokenizer;

import com.droid.utilities.Device;
import com.droid.utilities.CustomAdapter;

import com.droid.activities.R;
import com.droid.utilities.Connection;
import com.droid.utilities.ConstantsFile;
import com.droid.validators.InputFieldValidations;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class Doctor extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		// load up the layout
		setContentView(R.layout.doctorprofile);

		// get the button resource in the xml file and assign it to a local
		// variable of type Button
		TextView admintxt= (TextView) findViewById(R.id.admin_txt);
		admintxt.setVisibility(4);
		TableRow row1 = (TableRow)findViewById(R.id.row3);
		row1.setVisibility(4);
		TableRow row2 = (TableRow)findViewById(R.id.row4);
		row2.setVisibility(4);
		TableRow row3 = (TableRow)findViewById(R.id.row5);
		row3.setVisibility(4);
		TableRow row4 = (TableRow)findViewById(R.id.row6);
		row4.setVisibility(4);
		Button btnCreateDoctor = (Button) findViewById(R.id.create_doctor);
		btnCreateDoctor.setVisibility(4);
		Button btnViewDoctor = (Button) findViewById(R.id.viewdoc_button);
		btnViewDoctor.setVisibility(4);
		
		
		Button btnBack = (Button) findViewById(R.id.back_doctor);
		Button btnViewPatient = (Button) findViewById(R.id.view_button);

		Button btnCreate = (Button) findViewById(R.id.create_patient);
		Button btnSearch = (Button) findViewById(R.id.searchby);
		
		TextView logout_view = (TextView) findViewById(R.id.logout);

		final TextView lblResult = (TextView) findViewById(R.id.txt_doctorprofile);


		// When the back button is clicked, load up the Login screen

		btnBack.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				
									try {
					ConstantsFile.foreignContext = createPackageContext(
							ConstantsFile.packageName,
							Context.CONTEXT_IGNORE_SECURITY
									| Context.CONTEXT_INCLUDE_CODE);
					ConstantsFile.loginClass = (Class<Doctor_Login>) ConstantsFile.foreignContext
							.getClassLoader().loadClass(ConstantsFile.login);

					Intent intent = new Intent(Doctor.this,
							ConstantsFile.loginClass);
					startActivity(intent);
				} catch (ClassNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (NameNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}


			finish();			}
		});


		// When the Logout button is clicked, log out by loading up the login
		// screen
		logout_view.setOnClickListener(new OnClickListener() {
			@SuppressWarnings("unchecked")
			public void onClick(View v) {

				try {
					System.out.println("Logout initiated..");

					ConstantsFile.foreignContext = createPackageContext(
							ConstantsFile.packageName,
							Context.CONTEXT_IGNORE_SECURITY
									| Context.CONTEXT_INCLUDE_CODE);
					ConstantsFile.loginClass = (Class<Doctor_Login>) ConstantsFile.foreignContext
							.getClassLoader().loadClass(ConstantsFile.login);
					Intent intent = new Intent(Doctor.this,
							ConstantsFile.loginClass);
					startActivity(intent);

					finish();

					// moveTaskToBack(true);

				} catch (ClassNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (NameNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

			}

		});
	}

}
